package com.mimi.datastruct;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author gary
 * @Date 2020/12/6
 */
public class Sort {

    public static void main(String[] args) {
        int[] hight = {100, 100, 120, 130};
        int[] weith = {40, 30, 60, 50};
        int[] temp = new int[hight.length];
        int loc = 1;
        Map<Integer, Integer> map = new LinkedHashMap<>();
        for (int i = 0; i < hight.length; i++) {
            map.put(i, weith[i]);
        }
        for (int i = 0; i < hight.length-1; i++) {
            for (int j = i; j < hight.length  ; j++) {
                if (hight[j] < hight[i]) {
                    int temps = hight[i];
                    hight[i] = hight[j];
                    hight[j] =temps;
                    loc = loc+j;

                }else if
                 (hight[j] == hight[i] && map.get(j) < map.get(i)) {
                    int temps = hight[i];
                    hight[i] = hight[j];
                    hight[j] =temps;
                    loc = loc+j;
                }else {
                    loc = loc + i;
                }

            }

            temp[i]=loc;



        }


        System.out.println(Arrays.toString(temp));




    }




}
